<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form id="loginForm">
    <input type="text" name="username"> <br>
    <input type="text" name="password"> <br>
    <input type="submit" id="sub" value="登录">
</form>
<script>
    $(function () {
        $("#sub").click(function () {
           var data =  $("#loginForm").serialize();
           $.ajax({
               url:"",
               type:"post",
               data:data,
               success:function (result) {
                   if (result==1) {
                       //登录成功
                       location.href="index.html";
                   }
               }
           })
        })
    })
</script>
</body>
</html>